import 'package:flutter/material.dart';
import 'package:ichinesereader/themes/pageStyles.dart';
import 'package:sidebarx/sidebarx.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:get/get.dart';

class AdminReportSidebarX extends StatelessWidget {
  const AdminReportSidebarX({
    Key? key,
    required SidebarXController controller,
  })  : _controller = controller,
        super(key: key);
  final SidebarXController _controller;

  @override
  Widget build(BuildContext context) {
    Log.debug('start building AdminReportSidebarX');
    final PageStyles _pageStyles = PageStyles();

    return Container(
      margin: EdgeInsets.symmetric(vertical: 30.0, horizontal: 12.0),
      decoration: BoxDecoration(
        color: Colors.black.withOpacity(0.1),
        borderRadius: BorderRadius.circular(9.0),
      ),
      child: SidebarX(
        controller: _controller,
        theme: _pageStyles.pageSidebarXTheme(),
        extendedTheme: _pageStyles.pageSidebarXExtendTheme(),
        //footerDivider: divider,
        headerBuilder: (context, extended) {
          return Container(
            height: 120.0,
            child: Container(
              margin: EdgeInsets.symmetric(vertical: 18.0),
              padding: EdgeInsets.all(6.0),
              decoration: BoxDecoration(
                  color: Colors.white.withOpacity(0.3), shape: BoxShape.circle),
              child: Stack(alignment: Alignment.center, children: [
                Container(
                  width: 45.0,
                  height: 45.0,
                  decoration: BoxDecoration(
                    shape: BoxShape.circle,
                    color: Get.theme.primaryColor.withOpacity(0.8),
                    boxShadow: [
                      BoxShadow(
                        blurRadius: 1,
                        spreadRadius: 1,
                        color: Get.isDarkMode
                            ? Color(0xff555555)
                            : Colors.black.withOpacity(0.1),
                        offset: Offset(1, 1),
                      ),
                    ],
                  ),
                ),
                GestureDetector(
                    onTap: () {
                      if (GetPlatform.isWeb) {
                        Get.toNamed('/schooladmin/reports');
                      } else {
                        Get.offAndToNamed('/schooladmin/reports');
                      }
                    },
                    child: Icon(
                      Icons.table_chart_rounded,
                      color: Get.theme.primaryColorLight,
                    )),
              ]),
            ),
          );
        },
        items: [
          SidebarXItem(
            onTap: () {
              Get.toNamed('/schooladmin/reports/overall');
            },
            iconWidget: Tooltip(
              message: 'School Reports'.tr,
              child: Image.asset(
                'assets/images/evaluation/evaluation_books.png',
                height: 40,
                width: 40,
              ),
            ),
            label: 'School Reports'.tr,
          ),
          SidebarXItem(
            onTap: () {
              Get.toNamed('/schooladmin/reports/class');
            },
            iconWidget: Tooltip(
              message: 'Class Reports'.tr,
              child: Image.asset(
                'assets/images/evaluation/evaluation_books.png',
                height: 40,
                width: 40,
              ),
            ),
            label: 'Class Reports'.tr,
          ),
          SidebarXItem(
            onTap: () {
              Get.toNamed('/schooladmin/reports/student');
            },
            iconWidget: Tooltip(
              message: 'Student Reports'.tr,
              child: Image.asset(
                'assets/images/evaluation/evaluation_benchmark.png',
                height: 40,
                width: 40,
              ),
            ),
            label: 'Student Reports'.tr,
          ),
        ],
      ),
    );
  }
}
